package ynu.beggar.server.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import ynu.beggar.server.interceptor.AdminInterceptor;
import ynu.beggar.server.interceptor.LoginInterceptor;

/**
 * 配置拦截器
 * @author SelectedName(SN)
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/api/v1/user/*");
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/api/v1/forum/user/*");
        registry.addInterceptor(new AdminInterceptor()).addPathPatterns("/api/v1/admin/*");

        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
